import request from '@/config/axios'

// 资金记录 VO
export interface FundRecordVO {
  id: number // 主键ID
  recordNo: string // 记录编号
  merchantId: number // 商家ID
  merchantName: string // 商家名称
  recordType: number // 类型
  accountType: number // 账户类型
  accountId: string // 账户ID
  amount: number // 金额
  payerName: string // 付款方名称
  payerAccount: string // 付款方账号
  payerBank: string // 付款方开户行
  payeeName: string // 收款方名称
  payeeAccount: string // 收款方账号
  payeeBank: string // 收款方开户行
  transactionDate: Date // 交易日期
  transactionNo: string // 交易流水号
  voucherImages: string // 凭证图片URL
  recordStatus: number // 记录状态
  rejectReason: string // 拒绝理由
  status: number // 状态
}

// 资金记录 API
export const FundRecordApi = {
  // 查询资金记录分页
  getFundRecordPage: async (params: any) => {
    return await request.get({ url: `/juliang/fund-record/page`, params })
  },

  // 查询资金记录详情
  getFundRecordById: async (id: number) => {
    return await request.get({ url: `/juliang/fund-record/getById?id=` + id })
  },

  // 新增资金记录
  createFundRecord: async (data: FundRecordVO) => {
    return await request.post({ url: `/juliang/fund-record/create`, data })
  },

  // 修改资金记录
  updateFundRecord: async (data: FundRecordVO) => {
    return await request.post({ url: `/juliang/fund-record/update`, data })
  },


  auditRecord: async (id: number, status: number,rejectReason :string) => {
    const data = {
      id,
      status,
      rejectReason
    }
    return await request.post({ url: `/juliang/fund-record/audit`, data: data })
  },

  // 修改资金记录状态
  updateFundRecordStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/juliang/fund-record/updateStatus`, data: data })
  },

  // 删除资金记录
  deleteFundRecordById: async (id: number) => {
    return await request.get({ url: `/juliang/fund-record/delete?id=` + id })
  },

  // 导出资金记录 Excel
  exportFundRecord: async (params) => {
    return await request.download({ url: `/juliang/fund-record/export-excel`, params })
  },
}
